
//
//  DHAnchorDescView.m
//  Moment
//
//  Created by dllo on 15/12/26.
//  Copyright © 2015年 片刻. All rights reserved.
//

#import "DHAnchorDescView.h"

@implementation DHAnchorDescView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _radioArr = [NSMutableArray array];
        [self createView];
    }
    return self;
}
-(void)setPlayerRadio:(DHREPlayeRadio *)PlayerRadio{
    if (_PlayerRadio != PlayerRadio) {
        _PlayerRadio = PlayerRadio;
    }
    _radioArr = _PlayerRadio.moreting;
    NSLog(@"_PlayerRadio == %@",PlayerRadio);
    [_myTableView reloadData];

}
-(void)setRadioArr:(NSMutableArray *)radioArr{
    
    if (_radioArr != radioArr) {
        _radioArr = radioArr;
    }
}
-(void)createView{
    _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT -SCREEN_HEIGHT * 0.22) style:UITableViewStylePlain];
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    [_myTableView registerClass:[DHAnchordescTableViewCell class] forCellReuseIdentifier:@"DHAnchordescTableViewCell"];
    [_myTableView registerClass:[DHAchorFirstTableViewCell class] forCellReuseIdentifier:@"DHAchorFirstTableViewCell"];
    [self addSubview:_myTableView];
    _myTableView.bounces = NO;

}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (_radioArr.count != 0 ) {
        return 2;
    }
    else{
        return 0;
    }
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *firstCell = @"DHAchorFirstTableViewCell";
    static NSString *secondCell = @"DHAnchordescTableViewCell";
    DHAchorFirstTableViewCell *firstAnchorCell = [tableView dequeueReusableCellWithIdentifier:firstCell];
    DHAnchordescTableViewCell *secondAnchorCell = [tableView dequeueReusableCellWithIdentifier:secondCell];
    firstAnchorCell.selectionStyle = UITableViewCellAccessoryNone;
    secondAnchorCell.selectionStyle = UITableViewCellAccessoryNone;
    if (indexPath.row == 0) {
        firstAnchorCell.playerRadio = _PlayerRadio;
        return firstAnchorCell;
    }else{
        secondAnchorCell.nowArr = _PlayerRadio.moreting;
        return secondAnchorCell;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return SCREEN_HEIGHT * 0.3;
        
    }else{
        return SCREEN_HEIGHT * 0.48;
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
